package io.openim.android.demo;


import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.alibaba.android.arouter.facade.annotation.Route;

import io.openim.android.demo.ui.login.LoginActivity;
import io.openim.android.demo.ui.main.MainActivity;
import io.openim.android.ouicore.base.BaseApp;
import io.openim.android.ouicore.base.vm.injection.Easy;
import io.openim.android.ouicore.entity.LoginCertificate;
import io.openim.android.ouicore.utils.L;
import io.openim.android.ouicore.utils.Routes;
import io.openim.android.ouicore.vm.UserLogic;

@Route(path = Routes.Main.SPLASH)
public class SplashActivity extends AppCompatActivity {
    @SuppressLint("SourceLockedOrientationActivity")
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        super.onCreate(savedInstanceState);

        LoginCertificate loginCertificate = new LoginCertificate();
        loginCertificate.imToken ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVSUQiOiI1OTAxNTAzNjciLCJQbGF0Zm9ybSI6IkFuZHJvaWQiLCJleHAiOjE2ODYwMzc5OTIsIm5iZiI6MTY3ODI2MTY5MiwiaWF0IjoxNjc4MjYxOTkyfQ.Kj81DFlvuhJP4CMxiTvFSGytSCSUPDjeO1Za8uQvRzU";
        loginCertificate.chatToken="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiI1OTAxNTAzNjciLCJVc2VyVHlwZSI6MCwiZXhwIjoxNjg2MDM3OTkyLCJuYmYiOjE2NzgyNjE2OTIsImlhdCI6MTY3ODI2MTk5Mn0.hHAJGYsbd6q2O15c0ftsqIzWHCMr6f4Z63ePTRoj-5c";
        loginCertificate.nickname = "Oliver";
        loginCertificate.userID = "590150367";
        loginCertificate.faceURL = "http://img.touxiangwu" +
            ".com/zb_users/upload/2022/11/202211071667789271294192.jpg";

        loginCertificate.cache(this);

        UserLogic userLogic = Easy.find(UserLogic.class);
        if (userLogic.isCacheUser()) {
            startActivity(new Intent(this, MainActivity.class));
        } else
            startActivity(new Intent(this, LoginActivity.class));

        startActivity(new Intent(this, MainActivity.class));

        finish();
    }
}
